package com.quanquan.user.repository;

import com.quanquan.user.entity.SignIn;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 功能描述:
 *
 * @ClassName: SignInRepository
 * @Author: xiaoqianh丶
 * @Date: 2019-04-05 19:08
 * @Version: V1.0
 */
public interface SignInRepository  extends JpaRepository<SignIn, String>, JpaSpecificationExecutor<SignIn> {

    /**
     * 根据会员id查询签到记录，按时间排序
     * @param userId
     * @return
     */
    public List<SignIn> findByUserIdOrderByCreateTimeDesc(String userId);


    /**
     * 根据会员idhe和是否过期查询签到记录，按时间排序
     * @param userId
     * @param overdue
     * @return
     */
    public List<SignIn> findByUserIdAndOverdueOrderByCreateTimeDesc(String userId,Integer overdue);

    /**
     * 根据签到记录id和是否过期查询记录
     * @param id
     * @param overdue
     * @return
     */
    public SignIn findByIdAndOverdue(String id,Integer overdue);

    /**
     * 根据userid查询签到记录（当月）
     * @param userId
     * @return
     */
    public List<SignIn> findAllByUserIdOrderByCreateTime(String userId);

    @Query(value = "SELECT * FROM oo_sign_in",nativeQuery = true)
    List<SignIn> findAllSignin();


}
